package codingforgreat.class46;

public class Class02_Lc383 {
    public static boolean canConstruct(String ransomNote, String magazine) {
        int[] words = new int[26];
        char[] ran = ransomNote.toCharArray();
        char[] mag = magazine.toCharArray();
        for(int i = 0;i < mag.length;i++){
            words[mag[i] - 'a']++;
        }
        for(int i = 0;i < ran.length;i++){
            if(--words[ran[i] - 'a'] < 0){
                return false;
            }

        }
        return true;
    }

    public static void main(String[] args) {
        String a = "a";
        String b = "b";
        System.out.println(canConstruct(a,b));
    }
}
